/*jslint browser: true, nomen: true, es5: true*/
/*global $, jQuery, window, requirejs, require, define*/
(function (factory) {
    "use strict";
	if (typeof define === "function" && define.amd) {
		// AMD. Register as an anonymous module.
		define(factory);
	} else {
        // Browser globals
        window.lhmcv = window.lhmcv || {};
		window.lhmcv.Class = factory();
	}
}(function (noRequireJS) {
    "use strict";
    var initializing = false,
        Class = function () {};
    /**var ComboBox = Input.extend({
    init: function() {
        this._super(); //Input === this
    }});  */
    Class.extend = function extend(prop) {
        var father_prototype = this.prototype,
            father_object,
            name,
            //checkSuperInclude = /xyz/.test(function () {xyz;}) ? /\b_super\b/ : /.*/;
            checkSuperInclude = /\b_super\b/;
        initializing = true;
        father_object = new this();
        initializing = false;
        function makeFuncWithSuper(name, fn) {
            return function () {
                var tmp = this._super,
                    ret;
                this._super = father_prototype[name];
                ret = fn.apply(this, arguments);
                this._super = tmp;

                return ret;
            };
        }
        for (name in prop) {
            if (prop.hasOwnProperty(name)) {
                if (typeof prop[name] === "function" &&
                        typeof father_prototype[name] === "function" &&
                            checkSuperInclude.test(prop[name])) {
                    father_object[name] = makeFuncWithSuper.call(this, name, prop[name]);
                } else {
                    father_object[name] = prop[name];
                }
            }
        }
        
        function AfterExtendClass() {
            if (!initializing && this.init) {
                this.init.apply(this, arguments);
            }
        }
        AfterExtendClass.prototype = father_object;
        AfterExtendClass.prototype.constructor = Class;
        AfterExtendClass.extend = extend;
        return AfterExtendClass;
    };
    return Class;
}));